< previous page page_511 next page >

Page 511
9f31265bb40b592b1929e18a47ab28e5.gif
      cmdClose.Caption = "&Cancel"
   Else
      cmdClose.Caption = "&Close"
   End If
   cmdSave.Enabled = Not cmdSave.Enabled
   cmdNew.Enabled = Not cmdNew.Enabled
   cmdDelete.Enabled = Not cmdDelete.Enabled
   lstNames.Enabled = Not lstNames.Enabled
End Sub
You should also disable the list box so that the user cant click another employee while in the middle of editing or adding an employee record.
Deleting Data
To delete an employee record, the user needs to click the Delete command button. The Click event of the command button displays a message box asking the user to verify whether he or she really wants to delete this employees data. Heres the code:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub cmdDelete_Click()
   Dim intResponse As Integer
   Dim intIndex As Integer

   Beep
   intResponse = MsgBox("Delete the current Employee", _
                        vbYesNo + vbQuestion, _
                        "Delete Employee")
   If intResponse = vbYes Then
      intIndex = lstNames.ListIndex
      moRS.Delete
      lstNames.RemoveItem intIndex
      intResponse = ListReposition(lstNames, intIndex)
      If intResponse = -1 Then
         Call Form_Activate
      Else
         lstNames.ListIndex = intResponse
      End If
   End If
End Sub

 
< previous page page_511 next page >

If you like this book, buy it!